package Service.impl;

import DAO.BaseDao;
import DAO.impl.StoreService;

import java.util.Scanner;

public class PetStoreLogin extends BaseDao {
    /**
     * 宠物商店登录的方法
     * @return
     */
    public boolean petStoreLogin(){
        Test test = new Test();
        StoreService stroeDAOimpl = new StoreService();
        boolean flag=false;
        try {
            Scanner input=new Scanner(System.in);
            System.out.println("请先登录，请您先输入宠物商店的名字");
            String name=input.next();
            System.out.println("请您输入宠物商店的密码：");
            String password=input.next();
            conn=getConnection();
            String sq110="SELECT name,balance from petstore where name=? and password=?";
            state=conn.prepareStatement(sq110);
            rs=search(sq110, name,password);
            if(rs.next()){
                System.out.println("登录成功");
                stroeDAOimpl.PetStoreMake(name);
            }else{
                System.out.println("登录失败");
                test.login();
            }
        } catch (Exception e) {
            // TODO: handle exception
        }

        return false;
    }

}
